	function deleteOneT(url){
		if(window.confirm("你确定要删除此记录吗?")){
		var lastUrl = encodeURI(url);
		lastUrl = encodeURI(lastUrl);
		window.location=lastUrl;
		}
	}
	function deleteAllT(url){
	var obj = document.getElementsByName("deleteAll");
	
		var idList = "";
		var num = 0;
		for(var i = 0;i<obj.length;i++)
		{
			if(obj[i].checked)
			{
				num++;
				idList+=obj[i].value+",";
			}
		}
		if(num<1)
		{
			alert("没有选择记录无法删除!");
			return ;
		}
	 if(window.confirm("你确定要删除此记录吗?")){
	
	 	var lastUrl = encodeURI(url+"&idList="+idList);
		lastUrl = encodeURI(lastUrl);
		window.location=lastUrl;
	 }
	}
	
		//全选功能
	function check_allT(va)
	{
		var obj = document.getElementsByName(va);
		for(var o = 0;o<obj.length;o++)
		{
			if(obj[o].checked == true)
			{
				obj[o].checked = false;
			}else if(obj[o].checked == false)
			{
				obj[o].checked = true;
			}
		}
	}
	
	
	
	//通讯录全选功能
	/*function checkAdd_all(va)
	{
		var checkedO = document.getElementById("checkAll");
		
		var oo = document.all(va).children;//.length;//document.all(va).children.size();<ul><li>.......</ul></li>
		alert("oo==="+document.getElementById(va).innerHTML)
		var len = oo.length;
		alert("oo.tagName="+len);
		
		for(var i = 0;i<3;i++){
			var obj = oo[i];//循环每个<li>
			alert("tagName=="+obj.children.item(0).checked);
			if(checkedO.checked==true){
				alert("选择");
				obj.children.item(0).checked=true;
			}else if(checkedO.checked==false){
				obj.children.item(0).checked=false;
			}
			var chi = obj.children;
			var chiLen = chi.length;
			for(var o = 0;o<chiLen;o++){
				var vv = chi[o];
				
				if(vv.tagName=="UL"){
					if(obj.children.item(0).checked==true){
						vv.children.item(0).checked=true;
					}else{
						vv.children.item(0).checked=false;
					}
					ss(vv);
				}
			}
		}
		for(var o = 0;o<obj.length;o++)
		{
			if(obj[o].checked == true)
			{
				obj[o].checked = false;
			}else if(obj[o].checked == false)
			{
				obj[o].checked = true;
			}
		}
	}
	
	function ss(vvs){
		alert("aaaaaaaa");
		var oo = vvs.children;//.length;//document.all(va).children.size();<ul><li>.......</ul></li>
		var len = oo.length;
		alert("ovvvvvo.tagName="+len);
		
		for(var i = 0;i<3;i++){
			var obj = oo[i];//循环每个<li>
			var chi = obj.children;
			var chiLength = chi.length;
			if(vvs.children.item(0).checked==true){
				obj.children.item(0).checked=true;
			}else{
				obj.children.item(0).checked=false;
			}
			for(var o = 0;o<chiLength;o++){
				
				var vv =  chi[0];
				if(vv.tagName=="UL"){
					if(obj.children.children.item(0)==true){
						vv.children.children.item(0)=true;
					}else {
						vv.children.children.item(0)=false;
					}
					alert("vv.tagNItemame="+vv.children.item(1));
					ss(vv);
				}
			}
		}
	}	*/
	//address List
 function ts(obj){
        var tempArray=$(obj).parent("li").find(":checkbox");
        for(var i=0;i<tempArray.length;i++)
        {
               //alert(tempArray[i].checked+"");
               tempArray[i].checked=obj.checked;              
        }
        
    }
function addDir(url){
	var dirName = $("#dirName").val();
	if(dirName==""){
		alert("名称不能为空!");
		return ;
	}
	var fatherDirId = $("#fatherDirId").val();
	var dirLevel = $("#dirLevel").val();
	var lastUrl =url+"&dirName="+dirName+"&fatherDirId="+fatherDirId+"&dirLevel="+dirLevel;
	var last_Url = encodeURI(lastUrl);
	last_Url = encodeURI(last_Url);
	window.location= last_Url;
}
function modifyDir(url){
	var dirName = $("#dirName").val();
	if(dirName==""){
		alert("名称不能为空!");
		return ;
	}
	var dirId = $("#dirId").val();
	var dirLevel = $("#dirLevel").val();
	var lastUrl =url+"&dirName="+dirName+"&dirId="+dirId+"&dirLevel="+dirLevel;
	var last_Url = encodeURI(lastUrl);
	last_Url = encodeURI(last_Url);
	window.location= last_Url;
}
//delete a Directory and the directory Chilren by dirId
function deleteDir(url){
	window.location=url;
}
//add a linkMan
function addContact(url){
	var linkName = $("#linkName").val();
	var linkPhone = $("#linkPhone").val();
	if(linkName==""){
		alert("名称不能为空!");
		return ;
	}
	var bo = checkNum(linkPhone);
	if(!bo){
		return ;
	}
	var dirId = $("#dirId").val();
	var lastUrl = url+"&linkName="+linkName+"&linkPhone="+linkPhone+"&dirId="+dirId+"&jifen=0";
	var last_Url = encodeURI(lastUrl);
	last_Url = encodeURI(last_Url);
	window.location = last_Url;
	$mb.close();
}
//check the phone 
function checkNum(num){
	var strP=/^\d+(\.\d+)?$/; 
	if(!strP.test(num))
	{
		alert("请输入整数!");
		return false;
	}else{
		if(num.length<11){
			alert("手机号码位数不对!");
			return false;
		}else{
			return true;
		}
		
	}
}
//modify a linkMan
function modifyContact(url){
	var linkName = $("#linkName").val();
	var linkPhone = $("#linkPhone").val();
	var lastUrl = url+"&linkName="+linkName+"&linkPhone="+linkPhone;
	var last_Url = encodeURI(lastUrl);
	last_Url = encodeURI(last_Url);
	window.location= last_Url;
}
//modify a linkMan submit
function modifyContactSubmit(url){
	var linkName =$("#linkMan").val();//; $("#linkName").val();
	var linkPhone = $("#linkPhone").val();
	var birth = $("#birth").val();
	var quxian = $("#customerIntegral").val();
	var danwei = $("#danwei").val();
	var zhiwu = $("#zhiwu").val();
	var lastUrl = url+"&linkName="+linkName+"&linkPhone="+linkPhone+"&birth="+birth+"&customerIntegral="+quxian+"&danwei="+danwei+"&zhiwu="+zhiwu;
	var last_Url = encodeURI(lastUrl);
	last_Url = encodeURI(last_Url);
	window.location= last_Url;
}
//search the contact
function searchContact(url){
	 var linkName = $("#linkName").val();
	 var phone = $("#phone").val();
	 var lastUrl = url+"&linkName="+linkName+"&phone="+phone
	 var last_Url = encodeURI(lastUrl);
	 last_Url = encodeURI(last_Url);
	 window.location=last_Url;
}
function deleteAllContact(url){
	var obj = document.getElementsByName("deleteAll");
	
	var idList = "";
	var num = 0;
	for(var i = 0;i<obj.length;i++)
	{
		if(obj[i].checked)
		{
			num++;
			idList+=obj[i].value+",";
		}
	}
	if(num<1)
	{
		alert("没有选择记录无法删除!");
		return ;
	}
	var last_Url = url+"&idList="+idList;
	var lastUrl = encodeURI(last_Url);
	lastUrl = encodeURI(lastUrl);
	window.location=lastUrl;
}
//delete a contact
function deleteOneContact(url){
	var lastUrl = encodeURI(url);
	lastUrl = encodeURI(lastUrl);
	
	$.msgbox({
        height:150,
        width:200,
        content:{type:'confirm', content: '确定要删除吗?'},
        onClose:function(v){
            if(v) window.location=lastUrl;
        }
    });
	
	//window.location=lastUrl;
}
var Select = {   
    del : function(obj,e){   
        if((e.keyCode||e.which||e.charCode) == 8){   
            var opt = obj.options[0];   
            opt.text = opt.value = opt.value.substring(0, opt.value.length>0?opt.value.length-1:0);   
        }   
    },   
    write : function(obj,e){   
        if((e.keyCode||e.which||e.charCode) == 8)return ;   
        var opt = obj.options[0];   
        opt.selected = "selected";   
        opt.text = opt.value += String.fromCharCode(e.charCode||e.which||e.keyCode);   
       
    }   
}   
 
function test(va,nextVa){   
    var dirId=document.getElementById(va).value;
    $.ajax({type:"GET",url:"AddressServlet?method=getDirByParId&parDir="+dirId+"&nextDir="+nextVa,contentType:"application/x-www-form-urlencoded;charset=UTF-8",success:getNextSelect});
}   
function getNextSelect(date){
	var das=date.split(",");
	var str = $(das[1]);
	str.appendTo("#"+das[0]);
}
	